<template>
  <div>
  <el-table  :data="tableData"  stripe  style="width: 100%">
    <el-table-column type="index"   label="序号"  width="180"> </el-table-column>
    <el-table-column    prop="course.courseName"    label="课程名称"></el-table-column>
    <el-table-column      prop="courseDelete"  label="状态" :formatter = "formatterState" >
     <!-- {{deleteState == 1 ? '已完成':'未完成'}}--></el-table-column>
    <el-table-column      prop="scorePlay"    label="课件点播分数">    </el-table-column>
    <el-table-column      prop="scoreOntime"    label="在线时间分数">    </el-table-column>
    <el-table-column      prop="scoreTest"    label="小结测试分数">    </el-table-column>
    <el-table-column      prop="scoreExam"    label="课程结业考试分数">    </el-table-column>
    <el-table-column      prop="totalscore"    label="总成绩">
      <template slot-scope="scope">
        {{scope.row.scorePlay + scope.row.scoreOntime + scope.row.scoreTest + scope.row.scoreExam}}
      </template>
    </el-table-column>
  </el-table>
  <div class="block">
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="pageIndex"
      :page-size="pageSize"
      layout="prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</div>
</template>

<script>
  import {listScore} from '@/axios/api'   //注意此处严格的格式
  export default {
    data() {
      return {
        pageIndex:1,
        pageSize:10,
        total:100,
        totalScore:0,
        tableData: []
      }
    },
    methods: {

      formatterState(row , column) {
        if (row.courseDelete == 1) {
          return "未完成";
        } else {
          return "已完成";
        }
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.pageIndex = val;
        this.listScore()
      },
      getScoreMsg:function(){
        let param = {pageIndex: this.pageIndex}
        listScore(param).then (res => {
          this.total = res.resData.total,
          this.pageSize = res.resData.pageSize,
          this.tableData = res.resData.list;

        })
      }
    },

    //浏览器刷新则会立即加载
    mounted() {
      this.getScoreMsg();
    }

  }
</script>
